package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceRefuse;
import com.ruoyi.service.service.IServiceRefuseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 拒单或转介Controller
 * 
 * @author ZDL
 * @date 2024-12-09
 */
@RestController
@RequestMapping("/service/refuse")
public class ServiceRefuseController extends BaseController
{
    @Autowired
    private IServiceRefuseService serviceRefuseService;

    /**
     * 查询拒单或转介列表
     */
    @PreAuthorize("@ss.hasPermi('service:refuse:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceRefuse serviceRefuse)
    {
        startPage();
        List<ServiceRefuse> list = serviceRefuseService.selectServiceRefuseList(serviceRefuse);
        return getDataTable(list);
    }

    /**
     * 导出拒单或转介列表
     */
    @PreAuthorize("@ss.hasPermi('service:refuse:export')")
    @Log(title = "拒单或转介", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceRefuse serviceRefuse)
    {
        List<ServiceRefuse> list = serviceRefuseService.selectServiceRefuseList(serviceRefuse);
        ExcelUtil<ServiceRefuse> util = new ExcelUtil<ServiceRefuse>(ServiceRefuse.class);
        util.exportExcel(response, list, "拒单或转介数据");
    }

    /**
     * 获取拒单或转介详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:refuse:query')")
    @GetMapping(value = "/{refuseId}")
    public AjaxResult getInfo(@PathVariable("refuseId") Long refuseId)
    {
        return success(serviceRefuseService.selectServiceRefuseByRefuseId(refuseId));
    }

    /**
     * 新增拒单或转介
     */
    @PreAuthorize("@ss.hasPermi('service:refuse:add')")
    @Log(title = "拒单或转介", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceRefuse serviceRefuse)
    {
        return toAjax(serviceRefuseService.insertServiceRefuse(serviceRefuse));
    }

    /**
     * 修改拒单或转介
     */
    @PreAuthorize("@ss.hasPermi('service:refuse:edit')")
    @Log(title = "拒单或转介", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceRefuse serviceRefuse)
    {
        return toAjax(serviceRefuseService.updateServiceRefuse(serviceRefuse));
    }

    /**
     * 删除拒单或转介
     */
    @PreAuthorize("@ss.hasPermi('service:refuse:remove')")
    @Log(title = "拒单或转介", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refuseIds}")
    public AjaxResult remove(@PathVariable Long[] refuseIds)
    {
        return toAjax(serviceRefuseService.deleteServiceRefuseByRefuseIds(refuseIds));
    }
}
